--[[
dev by.EN_WATER
QQ:3774330268
mender by.Miao
QQ:3822304607
]]
local SansHubLib = {}
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local CONFIG_NAME = "SansHubUI_Config_v1"
local defaultConfig = {
    uiScale = 1.0,
    restoreButtonScale = 1.0,
    accentColor = {0, 200, 255},
    darkMode = true,
    autoMinimizeOnClose = false,
    windowTransparency = 0,
    cornerRadius = 15,
}
local config = table.clone(defaultConfig)
local success, savedJson = pcall(function()
    return game:GetService("Players").LocalPlayer:GetAttribute(CONFIG_NAME)
end)
if success and savedJson then
    local decoded = HttpService:JSONDecode(savedJson)
    for k, v in pairs(decoded) do
        if defaultConfig[k] ~= nil then
            config[k] = v
        end
    end
end
local function saveConfig()
    local json = HttpService:JSONEncode(config)
    game:GetService("Players").LocalPlayer:SetAttribute(CONFIG_NAME, json)
end

local function scale(v)
    return v * config.uiScale
end

local TOGGLE_ON_POS = UDim2.new(0, scale(16), 0, scale(1.5))
local TOGGLE_OFF_POS = UDim2.new(0, scale(2), 0, scale(1.5))
local TOGGLE_ACTIVE_COLOR = Color3.fromRGB(0, 200, 255)
local TOGGLE_INACTIVE_COLOR = Color3.fromRGB(255, 255, 255)
local SECTION_BORDER_COLOR = Color3.fromRGB(50, 50, 50)
local COMPONENT_BG_COLOR = Color3.fromRGB(30, 30, 40)
local SECTION_BG_COLOR = Color3.fromRGB(25, 25, 35)

local function isMobile()
    return UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled
end

local function createCorner(parent, radius)
    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0, radius or scale(8))
    corner.Parent = parent
    return corner
end

local function createStroke(parent, color, thickness, transparency)
    local stroke = Instance.new("UIStroke")
    stroke.Color = color or Color3.fromRGB(255, 255, 255)
    stroke.Thickness = thickness or scale(1)
    stroke.Transparency = transparency or 0.5
    stroke.Parent = parent
    return stroke
end

local function createSeparator(parent, position)
    local separator = Instance.new("Frame")
    separator.Size = UDim2.new(1, -scale(20), 0, scale(1))
    separator.Position = position
    separator.BackgroundColor3 = SECTION_BORDER_COLOR
    separator.BorderSizePixel = 0
    separator.Parent = parent
    return separator
end

local function smoothTween(object, properties, duration, easingStyle, easingDirection)
    local tweenInfo = TweenInfo.new(duration or 0.2, easingStyle or Enum.EasingStyle.Quad, easingDirection or Enum.EasingDirection.Out)
    local tween = TweenService:Create(object, tweenInfo, properties)
    tween:Play()
    return tween
end

function SansHubLib:CreateWindow(name, version)
    local screenGui = Instance.new("ScreenGui")
    screenGui.Name = "SansHubLib"
    screenGui.ResetOnSpawn = false
    screenGui.Parent = game:GetService("CoreGui") or game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

    local baseWidth, baseHeight = 350, 250
    local restoreBaseSize = 50

    local mainFrame = Instance.new("Frame")
    mainFrame.Size = UDim2.new(0, scale(baseWidth), 0, scale(baseHeight))
    mainFrame.Position = UDim2.new(0.5, -scale(baseWidth)/2, 0.5, -scale(baseHeight)/2)
    mainFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 30)
    mainFrame.BackgroundTransparency = config.windowTransparency
    mainFrame.BorderSizePixel = 0
    mainFrame.Active = true
    mainFrame.Draggable = false
    mainFrame.Parent = screenGui
    mainFrame.ClipsDescendants = true

    local mainCorner = createCorner(mainFrame, config.cornerRadius)
    local mainStroke = createStroke(mainFrame)

    local titleBar = Instance.new("Frame")
    titleBar.Size = UDim2.new(1, 0, 0, scale(50))
    titleBar.BackgroundTransparency = 1
    titleBar.Parent = mainFrame

    local player = Players.LocalPlayer
    local avatar = Instance.new("ImageLabel")
    avatar.Size = UDim2.new(0, scale(40), 0, scale(40))
    avatar.Position = UDim2.new(0, scale(10), 0, scale(5))
    avatar.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
    avatar.BorderSizePixel = 0
    avatar.Parent = titleBar
    createCorner(avatar, scale(20))
    pcall(function()
        avatar.Image = Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
    end)

    local titleMain = Instance.new("TextLabel")
    titleMain.Size = UDim2.new(0, scale(200), 0, scale(25))
    titleMain.Position = UDim2.new(0, scale(60), 0, scale(10))
    titleMain.BackgroundTransparency = 1
    titleMain.Text = name or "SansHub UI"
    titleMain.TextColor3 = Color3.fromRGB(255, 255, 255)
    titleMain.TextSize = scale(20)
    titleMain.Font = Enum.Font.SourceSansBold
    titleMain.TextXAlignment = Enum.TextXAlignment.Left
    titleMain.Parent = titleBar

    local titleSub = Instance.new("TextLabel")
    titleSub.Size = UDim2.new(0, scale(200), 0, scale(15))
    titleSub.Position = UDim2.new(0, scale(60), 0, scale(35))
    titleSub.BackgroundTransparency = 1
    titleSub.Text = version or "Version 1.0"
    titleSub.TextColor3 = Color3.fromRGB(0, 200, 255)
    titleSub.TextSize = scale(12)
    titleSub.Font = Enum.Font.SourceSansBold
    titleSub.TextXAlignment = Enum.TextXAlignment.Left
    titleSub.Parent = titleBar

    local configButton = Instance.new("TextButton")
    configButton.Size = UDim2.new(0, scale(25), 0, scale(25))
    configButton.Position = UDim2.new(1, -scale(95), 0, scale(10))
    configButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
    configButton.BackgroundTransparency = 0
    configButton.Text = "⚙"
    configButton.TextColor3 = Color3.fromRGB(255, 255, 255)
    configButton.TextSize = scale(16)
    configButton.Font = Enum.Font.GothamBold
    configButton.Modal = true
    configButton.Parent = titleBar
    createCorner(configButton, scale(10))
    createStroke(configButton)

    createSeparator(mainFrame, UDim2.new(0, scale(10), 0, scale(50)))

    local minimizeButton = Instance.new("TextButton")
    minimizeButton.Size = UDim2.new(0, scale(25), 0, scale(25))
    minimizeButton.Position = UDim2.new(1, -scale(65), 0, scale(10))
    minimizeButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
    minimizeButton.BackgroundTransparency = 0
    minimizeButton.Text = "—"
    minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
    minimizeButton.TextSize = scale(16)
    minimizeButton.Font = Enum.Font.GothamBold
    minimizeButton.Modal = true
    minimizeButton.Parent = titleBar
    createCorner(minimizeButton, scale(10))
    createStroke(minimizeButton)

    local closeButton = Instance.new("TextButton")
    closeButton.Size = UDim2.new(0, scale(25), 0, scale(25))
    closeButton.Position = UDim2.new(1, -scale(35), 0, scale(10))
    closeButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
    closeButton.BackgroundTransparency = 0
    closeButton.Text = "×"
    closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
    closeButton.TextSize = scale(16)
    closeButton.Font = Enum.Font.GothamBold
    closeButton.Modal = true
    closeButton.Parent = titleBar
    createCorner(closeButton, scale(10))
    createStroke(closeButton)

    local restoreButton = Instance.new("TextButton")
    restoreButton.Size = UDim2.new(0, scale(restoreBaseSize) * config.restoreButtonScale, 0, scale(restoreBaseSize) * config.restoreButtonScale)
    restoreButton.Position = UDim2.new(0, scale(10), 0, scale(10))
    restoreButton.BackgroundColor3 = Color3.fromRGB(20, 20, 30)
    restoreButton.BackgroundTransparency = config.windowTransparency
    restoreButton.Text = name and string.sub(name, 1, 5) or "Sans"
    restoreButton.TextColor3 = Color3.fromRGB(255, 255, 255)
    restoreButton.TextSize = scale(14)
    restoreButton.Font = Enum.Font.GothamBold
    restoreButton.Visible = false
    restoreButton.Active = true
    restoreButton.Parent = screenGui
    local restoreCorner = createCorner(restoreButton, config.cornerRadius)
    createStroke(restoreButton)

    local draggingRestore = false
    local dragStartRestore = Vector2.new(0, 0)
    local restoreStart = Vector2.new(0, 0)
    local function updateRestoreInput(input)
        local delta = input.Position - dragStartRestore
        restoreButton.Position = UDim2.fromOffset(
            restoreStart.X + delta.X,
            restoreStart.Y + delta.Y
        )
    end
    restoreButton.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            draggingRestore = true
            dragStartRestore = input.Position
            restoreStart = restoreButton.AbsolutePosition
            if input.UserInputType == Enum.UserInputType.Touch then
                local conn
                conn = RunService.Heartbeat:Connect(function()
                    if draggingRestore then
                        updateRestoreInput(UserInputService:GetMouseLocation())
                    else
                        conn:Disconnect()
                    end
                end)
            end
        end
    end)
    restoreButton.InputChanged:Connect(function(input)
        if draggingRestore and input.UserInputType == Enum.UserInputType.MouseMovement then
            updateRestoreInput(input)
        end
    end)
    restoreButton.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            draggingRestore = false
        end
    end)

    local tabFrame = Instance.new("ScrollingFrame")
    tabFrame.Size = UDim2.new(0, scale(80), 1, -scale(70))
    tabFrame.Position = UDim2.new(0, scale(10), 0, scale(60))
    tabFrame.BackgroundTransparency = 1
    tabFrame.ScrollBarThickness = scale(4)
    tabFrame.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 100)
    tabFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
    tabFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y
    tabFrame.Parent = mainFrame

    local tabLayout = Instance.new("UIListLayout")
    tabLayout.Padding = UDim.new(0, scale(5))
    tabLayout.SortOrder = Enum.SortOrder.LayoutOrder
    tabLayout.Parent = tabFrame

    local contentFrame = Instance.new("ScrollingFrame")
    contentFrame.Size = UDim2.new(0, scale(250), 1, -scale(70))
    contentFrame.Position = UDim2.new(0, scale(100), 0, scale(60))
    contentFrame.BackgroundTransparency = 1
    contentFrame.ScrollBarThickness = scale(5)
    contentFrame.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 100)
    contentFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y
    contentFrame.Parent = mainFrame

    local contentLayout = Instance.new("UIListLayout", contentFrame)
    contentLayout.Padding = UDim.new(0, scale(10))
    contentLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center

    local dragging = false
    local dragStart = Vector2.new(0, 0)
    local frameStart = Vector2.new(0, 0)
    local function updateInput(input)
        local delta = input.Position - dragStart
        mainFrame.Position = UDim2.fromOffset(
            frameStart.X + delta.X,
            frameStart.Y + delta.Y
        )
    end
    titleBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = true
            dragStart = input.Position
            frameStart = mainFrame.AbsolutePosition
            if input.UserInputType == Enum.UserInputType.Touch then
                local conn
                conn = RunService.Heartbeat:Connect(function()
                    if dragging then
                        updateInput(UserInputService:GetMouseLocation())
                    else
                        conn:Disconnect()
                    end
                end)
            end
        end
    end)
    titleBar.InputChanged:Connect(function(input)
        if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
            updateInput(input)
        end
    end)
    titleBar.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = false
        end
    end)

    local isMinimized = false
    minimizeButton.MouseButton1Click:Connect(function()
        task.wait(0.1)
        if not isMinimized then
            smoothTween(mainFrame, {Position = UDim2.new(0.5, -scale(175), 1.5, 0)}, 0.3)
            task.wait(0.3)
            mainFrame.Visible = false
            restoreButton.Visible = true
            minimizeButton.Text = "□"
            isMinimized = true
        else
            mainFrame.Visible = true
            smoothTween(mainFrame, {Position = UDim2.new(0.5, -scale(175), 0.5, -scale(125))}, 0.3)
            restoreButton.Visible = false
            minimizeButton.Text = "—"
            isMinimized = false
        end
    end)

    restoreButton.MouseButton1Click:Connect(function()
        task.wait(0.1)
        mainFrame.Visible = true
        smoothTween(mainFrame, {Position = UDim2.new(0.5, -scale(175), 0.5, -scale(125))}, 0.3)
        restoreButton.Visible = false
        minimizeButton.Text = "—"
        isMinimized = false
    end)

    closeButton.MouseButton1Click:Connect(function()
    if config.autoMinimizeOnClose then
        task.wait(0.1)
        if not isMinimized then
            smoothTween(mainFrame, {Position = UDim2.new(0.5, -scale(175), 1.5, 0)}, 0.3)
            task.wait(0.3)
            mainFrame.Visible = false
            restoreButton.Visible = true
            minimizeButton.Text = "□"
            isMinimized = true
        end
    else
        local confirmFrame = Instance.new("Frame")
        confirmFrame.Size = UDim2.new(0, scale(250), 0, scale(120))
        confirmFrame.Position = UDim2.new(0.5, -scale(125), 0.5, -scale(60))
        confirmFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
        confirmFrame.Parent = screenGui
        createCorner(confirmFrame, scale(15))
        createStroke(confirmFrame)

        local confirmTitle = Instance.new("TextLabel")
        confirmTitle.Size = UDim2.new(1, 0, 0, scale(30))
        confirmTitle.Position = UDim2.new(0, 0, 0, scale(10))
        confirmTitle.BackgroundTransparency = 1
        confirmTitle.Text = "关闭UI?"
        confirmTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
        confirmTitle.TextSize = scale(18)
        confirmTitle.Font = Enum.Font.GothamBold
        confirmTitle.Parent = confirmFrame

        local confirmText = Instance.new("TextLabel")
        confirmText.Size = UDim2.new(1, -scale(20), 0, scale(40))
        confirmText.Position = UDim2.new(0, scale(10), 0, scale(40))
        confirmText.BackgroundTransparency = 1
        confirmText.Text = "你确定要关闭吗？"
        confirmText.TextColor3 = Color3.fromRGB(200, 200, 200)
        confirmText.TextSize = scale(14)
        confirmText.Font = Enum.Font.Gotham
        confirmText.TextWrapped = true
        confirmText.Parent = confirmFrame

        local confirmButton = Instance.new("TextButton")
        confirmButton.Size = UDim2.new(0, scale(100), 0, scale(30))
        confirmButton.Position = UDim2.new(0.5, -scale(110), 1, -scale(40))
        confirmButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
        confirmButton.Text = "确定"
        confirmButton.TextColor3 = Color3.fromRGB(255, 255, 255)
        confirmButton.TextSize = scale(14)
        confirmButton.Font = Enum.Font.Gotham
        confirmButton.Parent = confirmFrame
        createCorner(confirmButton, scale(8))
        createStroke(confirmButton)

        local cancelButton = Instance.new("TextButton")
        cancelButton.Size = UDim2.new(0, scale(100), 0, scale(30))
        cancelButton.Position = UDim2.new(0.5, scale(10), 1, -scale(40))
        cancelButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
        cancelButton.Text = "取消"
        cancelButton.TextColor3 = Color3.fromRGB(255, 255, 255)
        cancelButton.TextSize = scale(14)
        cancelButton.Font = Enum.Font.Gotham
        cancelButton.Parent = confirmFrame
        createCorner(cancelButton, scale(8))
        createStroke(cancelButton)

        confirmButton.MouseButton1Click:Connect(function()
            smoothTween(confirmFrame, {Size = UDim2.new(0, 0, 0, 0), Position = UDim2.new(0.5, 0, 0.5, 0)}, 0.2)
            task.wait(0.2)
            confirmFrame:Destroy()
            smoothTween(mainFrame, {Size = UDim2.new(0, 0, 0, 0), Position = UDim2.new(0.5, 0, 0.5, 0)}, 0.3)
            task.wait(0.3)
            screenGui:Destroy()
        end)

        cancelButton.MouseButton1Click:Connect(function()
            smoothTween(confirmFrame, {Size = UDim2.new(0, 0, 0, 0), Position = UDim2.new(0.5, 0, 0.5, 0)}, 0.2)
            task.wait(0.2)
            confirmFrame:Destroy()
        end)
    end
end)

    local function refreshUIScale()
        local w = scale(baseWidth)
        local h = scale(baseHeight)
        mainFrame.Size = UDim2.new(0, w, 0, h)
        mainFrame.Position = UDim2.new(0.5, -w/2, 0.5, -h/2)
        mainFrame.BackgroundTransparency = config.windowTransparency
        mainCorner.CornerRadius = UDim.new(0, config.cornerRadius)
        restoreButton.Size = UDim2.new(0, scale(restoreBaseSize) * config.restoreButtonScale, 0, scale(restoreBaseSize) * config.restoreButtonScale)
        restoreCorner.CornerRadius = UDim.new(0, config.cornerRadius)
        tabFrame.Size = UDim2.new(0, scale(80), 1, -scale(70))
        tabFrame.Position = UDim2.new(0, scale(10), 0, scale(60))
        contentFrame.Size = UDim2.new(0, scale(250), 1, -scale(70))
        contentFrame.Position = UDim2.new(0, scale(100), 0, scale(60))
        titleBar.Size = UDim2.new(1, 0, 0, scale(50))
        avatar.Size = UDim2.new(0, scale(40), 0, scale(40))
        avatar.Position = UDim2.new(0, scale(10), 0, scale(5))
        titleMain.Size = UDim2.new(0, scale(200), 0, scale(25))
        titleMain.Position = UDim2.new(0, scale(60), 0, scale(10))
        titleMain.TextSize = scale(20)
        titleSub.Size = UDim2.new(0, scale(200), 0, scale(15))
        titleSub.Position = UDim2.new(0, scale(60), 0, scale(35))
        titleSub.TextSize = scale(12)
        configButton.Size = UDim2.new(0, scale(25), 0, scale(25))
        configButton.Position = UDim2.new(1, -scale(95), 0, scale(10))
        configButton.TextSize = scale(16)
        minimizeButton.Size = UDim2.new(0, scale(25), 0, scale(25))
        minimizeButton.Position = UDim2.new(1, -scale(65), 0, scale(10))
        minimizeButton.TextSize = scale(16)
        closeButton.Size = UDim2.new(0, scale(25), 0, scale(25))
        closeButton.Position = UDim2.new(1, -scale(35), 0, scale(10))
        closeButton.TextSize = scale(16)
    end

    local tabs = {}
    local currentTab = nil
    local configTabFrame = nil
    local lastNormalTab = nil

    function tabs:tab(name)
        local tabCount = #self
        local tabButton = Instance.new("TextButton")
        tabButton.Size = UDim2.new(1, -scale(10), 0, scale(30))
        tabButton.LayoutOrder = tabCount
        tabButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
        tabButton.BackgroundTransparency = 0.5
        tabButton.Text = name:upper()
        tabButton.TextColor3 = Color3.fromRGB(255, 255, 255)
        tabButton.TextSize = scale(12)
        tabButton.Font = Enum.Font.Gotham
        tabButton.Modal = true
        tabButton.Parent = tabFrame
        createStroke(tabButton)
        createCorner(tabButton)

        if name == "(Hidden) Config" then
            tabButton.Visible = false
        end

        local highlight = Instance.new("Frame")
        highlight.Size = UDim2.new(0, scale(3), 0.6, 0)
        highlight.Position = UDim2.new(0, -scale(5), 0.2, 0)
        highlight.BackgroundColor3 = Color3.fromRGB(0, 200, 255)
        highlight.BackgroundTransparency = 0
        highlight.Visible = tabCount == 0
        highlight.Parent = tabButton

        local tabContentFrame = Instance.new("Frame")
        tabContentFrame.Size = UDim2.new(1, 0, 0, 0)
        tabContentFrame.AutomaticSize = Enum.AutomaticSize.Y
        tabContentFrame.BackgroundTransparency = 1
        tabContentFrame.Visible = tabCount == 0
        tabContentFrame.Parent = contentFrame

        local tabContentLayout = Instance.new("UIListLayout", tabContentFrame)
        tabContentLayout.Padding = UDim.new(0, scale(10))
        tabContentLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center

        if tabCount == 0 then
            currentTab = {button = tabButton, frame = tabContentFrame, highlight = highlight}
        end

        tabButton.MouseButton1Click:Connect(function()
            if currentTab then
                currentTab.highlight.Visible = false
                smoothTween(currentTab.frame, {Position = UDim2.new(1, 0, 0, 0)}, 0.2)
                currentTab.frame.Visible = false
            end
            currentTab = {button = tabButton, frame = tabContentFrame, highlight = highlight}
            highlight.Visible = true
            tabContentFrame.Visible = true
            tabContentFrame.Position = UDim2.new(-1, 0, 0, 0)
            smoothTween(tabContentFrame, {Position = UDim2.new(0, 0, 0, 0)}, 0.2)
        end)

        local tabFunctions = {}
        local componentsContainer = Instance.new("Frame")
        componentsContainer.Size = UDim2.new(1, 0, 0, 0)
        componentsContainer.AutomaticSize = Enum.AutomaticSize.Y
        componentsContainer.BackgroundTransparency = 1
        componentsContainer.Parent = tabContentFrame

        local componentsLayout = Instance.new("UIListLayout", componentsContainer)
        componentsLayout.Padding = UDim.new(0, scale(10))
        componentsLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center

        function tabFunctions:toggle(name, description, callback)
            local toggleFrame = Instance.new("Frame")
            toggleFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
            toggleFrame.BackgroundColor3 = COMPONENT_BG_COLOR
            toggleFrame.BackgroundTransparency = 0
            toggleFrame.Parent = componentsContainer
            createCorner(toggleFrame, scale(6))
            createStroke(toggleFrame)

            local desc = Instance.new("TextLabel")
            desc.Size = UDim2.new(1, -scale(50), 0, scale(12))
            desc.Position = UDim2.new(0, scale(5), 0, scale(2))
            desc.BackgroundTransparency = 1
            desc.Text = description
            desc.TextColor3 = Color3.fromRGB(150, 150, 150)
            desc.TextSize = scale(10)
            desc.Font = Enum.Font.Gotham
            desc.TextXAlignment = Enum.TextXAlignment.Left
            desc.Parent = toggleFrame

            local toggle = Instance.new("TextButton")
            toggle.Size = UDim2.new(0, scale(30), 0, scale(15))
            toggle.Position = UDim2.new(1, -scale(35), 0, scale(10))
            toggle.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
            toggle.BackgroundTransparency = 0
            toggle.Text = ""
            toggle.Modal = true
            toggle.Parent = toggleFrame
            createCorner(toggle, scale(6))

            local toggleCircle = Instance.new("Frame")
            toggleCircle.Size = UDim2.new(0, scale(12), 0, scale(12))
            toggleCircle.Position = TOGGLE_OFF_POS
            toggleCircle.BackgroundColor3 = TOGGLE_INACTIVE_COLOR
            toggleCircle.Parent = toggle
            createCorner(toggleCircle, scale(6))

            local toggleLabel = Instance.new("TextLabel")
            toggleLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
            toggleLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
            toggleLabel.BackgroundTransparency = 1
            toggleLabel.Text = name
            toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
            toggleLabel.TextSize = scale(14)
            toggleLabel.Font = Enum.Font.Gotham
            toggleLabel.TextXAlignment = Enum.TextXAlignment.Left
            toggleLabel.Parent = toggleFrame

            local isActive = false
            local function updateToggle()
                if isActive then
                    smoothTween(toggleCircle, {Position = TOGGLE_ON_POS, BackgroundColor3 = TOGGLE_ACTIVE_COLOR}, 0.2)
                else
                    smoothTween(toggleCircle, {Position = TOGGLE_OFF_POS, BackgroundColor3 = TOGGLE_INACTIVE_COLOR}, 0.2)
                end
                if callback then callback(isActive) end
            end

            toggle.MouseButton1Click:Connect(function()
                isActive = not isActive
                updateToggle()
            end)

            local toggleObj = {}
            function toggleObj:Set(value)
                isActive = value
                updateToggle()
            end
            function toggleObj:Get()
                return isActive
            end
            return toggleObj
        end

        function tabFunctions:button(name, description, callback)
            local buttonFrame = Instance.new("Frame")
            buttonFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
            buttonFrame.BackgroundColor3 = COMPONENT_BG_COLOR
            buttonFrame.BackgroundTransparency = 0
            buttonFrame.Parent = componentsContainer
            createCorner(buttonFrame, scale(6))
            createStroke(buttonFrame)

            local desc = Instance.new("TextLabel")
            desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
            desc.Position = UDim2.new(0, scale(5), 0, scale(2))
            desc.BackgroundTransparency = 1
            desc.Text = description
            desc.TextColor3 = Color3.fromRGB(150, 150, 150)
            desc.TextSize = scale(10)
            desc.Font = Enum.Font.Gotham
            desc.TextXAlignment = Enum.TextXAlignment.Left
            desc.Parent = buttonFrame

            local button = Instance.new("TextButton")
            button.Size = UDim2.new(1, -scale(20), 0, scale(20))
            button.Position = UDim2.new(0, scale(10), 0, scale(15))
            button.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
            button.BackgroundTransparency = 0
            button.Text = name
            button.TextColor3 = Color3.fromRGB(255, 255, 255)
            button.TextSize = scale(14)
            button.Font = Enum.Font.Gotham
            button.Parent = buttonFrame
            createCorner(button, scale(6))

            button.MouseButton1Click:Connect(function()
                smoothTween(button, {Size = UDim2.new(1, -scale(25), 0, scale(18))}, 0.1)
                task.delay(0.1, function()
                    smoothTween(button, {Size = UDim2.new(1, -scale(20), 0, scale(20))}, 0.1)
                end)
                if callback then callback() end
            end)
        end

        function tabFunctions:slider(name, description, min, max, default, callback)
            local sliderFrame = Instance.new("Frame")
            sliderFrame.Size = UDim2.new(1, -scale(20), 0, scale(50))
            sliderFrame.BackgroundColor3 = COMPONENT_BG_COLOR
            sliderFrame.BackgroundTransparency = 0
            sliderFrame.Parent = componentsContainer
            createCorner(sliderFrame, scale(6))
            createStroke(sliderFrame)

            local desc = Instance.new("TextLabel")
            desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
            desc.Position = UDim2.new(0, scale(5), 0, scale(2))
            desc.BackgroundTransparency = 1
            desc.Text = description
            desc.TextColor3 = Color3.fromRGB(150, 150, 150)
            desc.TextSize = scale(10)
            desc.Font = Enum.Font.Gotham
            desc.TextXAlignment = Enum.TextXAlignment.Left
            desc.Parent = sliderFrame

            local sliderLabel = Instance.new("TextLabel")
            sliderLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
            sliderLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
            sliderLabel.BackgroundTransparency = 1
            sliderLabel.Text = name
            sliderLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
            sliderLabel.TextSize = scale(14)
            sliderLabel.Font = Enum.Font.Gotham
            sliderLabel.TextXAlignment = Enum.TextXAlignment.Left
            sliderLabel.Parent = sliderFrame

            local valueLabel = Instance.new("TextLabel")
            valueLabel.Size = UDim2.new(0, scale(50), 0, scale(18))
            valueLabel.Position = UDim2.new(1, -scale(55), 0, scale(14))
            valueLabel.BackgroundTransparency = 1
            valueLabel.Text = tostring(default)
            valueLabel.TextColor3 = Color3.fromRGB(0, 200, 255)
            valueLabel.TextSize = scale(14)
            valueLabel.Font = Enum.Font.GothamBold
            valueLabel.TextXAlignment = Enum.TextXAlignment.Right
            valueLabel.Parent = sliderFrame

            local sliderTrack = Instance.new("Frame")
            sliderTrack.Size = UDim2.new(1, -scale(20), 0, scale(5))
            sliderTrack.Position = UDim2.new(0, scale(10), 1, -scale(15))
            sliderTrack.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
            sliderTrack.Parent = sliderFrame
            createCorner(sliderTrack, scale(3))

            local sliderFill = Instance.new("Frame")
            sliderFill.Size = UDim2.new(0, 0, 1, 0)
            sliderFill.Position = UDim2.new(0, 0, 0, 0)
            sliderFill.BackgroundColor3 = Color3.fromRGB(0, 200, 255)
            sliderFill.Parent = sliderTrack
            createCorner(sliderFill, scale(3))

            local sliderHitbox = Instance.new("TextButton")
            sliderHitbox.Size = UDim2.new(1, 0, 0, scale(30))
            sliderHitbox.Position = UDim2.new(0, 0, 0.5, -scale(15))
            sliderHitbox.BackgroundTransparency = 1
            sliderHitbox.ZIndex = sliderTrack.ZIndex + 1
            sliderHitbox.Modal = true
            sliderHitbox.Parent = sliderFrame

            local sliderButton = Instance.new("Frame")
            sliderButton.Size = UDim2.new(0, scale(20), 0, scale(20))
            sliderButton.AnchorPoint = Vector2.new(0.5, 0.5)
            sliderButton.Position = UDim2.new(0, 0, 0.5, 0)
            sliderButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
            sliderButton.Parent = sliderTrack
            createCorner(sliderButton, scale(10))

            local currentValue = math.clamp(default or min, min, max)
            local isDragging = false
            local dragStartX = 0
            local startPos = 0

            local function updateSlider(value)
                currentValue = math.clamp(value, min, max)
                local ratio = (currentValue - min) / (max - min)
                local fillSize = scale(20) * ratio
                local fillRatio = ratio
                sliderFill.Size = UDim2.new(fillRatio, 0, 1, 0)
                sliderButton.Position = UDim2.new(ratio, 0, 0.5, 0)
                valueLabel.Text = string.format("%.2f", currentValue)
                if callback then callback(currentValue) end
            end

            updateSlider(currentValue)

            local inputChangedConn = nil
            local inputEndedConn = nil

            local function beginDrag(input)
                isDragging = true
                dragStartX = input.Position.X
                startPos = (sliderButton.Position.X.Scale * sliderTrack.AbsoluteSize.X + sliderButton.Position.X.Offset)
                if not inputChangedConn then
                    inputChangedConn = UserInputService.InputChanged:Connect(function(inputObj, gp)
                        if isDragging and not gp and (inputObj.UserInputType == Enum.UserInputType.MouseMovement or inputObj.UserInputType == Enum.UserInputType.Touch) then
                            local deltaX = inputObj.Position.X - dragStartX
                            local newX = startPos + deltaX
                            local clampedX = math.clamp(newX, 0, sliderTrack.AbsoluteSize.X)
                            local ratio = clampedX / sliderTrack.AbsoluteSize.X
                            local value = min + ratio * (max - min)
                            updateSlider(value)
                        end
                    end)
                end
                if not inputEndedConn then
                    inputEndedConn = UserInputService.InputEnded:Connect(function(inputObj, _)
                        if inputObj.UserInputType == Enum.UserInputType.MouseButton1 or inputObj.UserInputType == Enum.UserInputType.Touch then
                            isDragging = false
                            if inputChangedConn then
                                inputChangedConn:Disconnect()
                                inputChangedConn = nil
                            end
                            if inputEndedConn then
                                inputEndedConn:Disconnect()
                                inputEndedConn = nil
                            end
                        end
                    end)
                end
            end

            sliderButton.InputBegan:Connect(beginDrag)
            sliderHitbox.InputBegan:Connect(beginDrag)

            local sliderObj = {}
            function sliderObj:Set(value)
                updateSlider(value)
            end
            function sliderObj:Get()
                return currentValue
            end
            return sliderObj
        end

        function tabFunctions:dropdown(name, description, options, default, callback)
            local dropdownFrame = Instance.new("Frame")
            dropdownFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
            dropdownFrame.BackgroundColor3 = COMPONENT_BG_COLOR
            dropdownFrame.BackgroundTransparency = 0
            dropdownFrame.Parent = componentsContainer
            createCorner(dropdownFrame, scale(6))
            createStroke(dropdownFrame)

            local desc = Instance.new("TextLabel")
            desc.Size = UDim2.new(1, -scale(50), 0, scale(12))
            desc.Position = UDim2.new(0, scale(5), 0, scale(2))
            desc.BackgroundTransparency = 1
            desc.Text = description
            desc.TextColor3 = Color3.fromRGB(150, 150, 150)
            desc.TextSize = scale(10)
            desc.Font = Enum.Font.Gotham
            desc.TextXAlignment = Enum.TextXAlignment.Left
            desc.Parent = dropdownFrame

            local dropdownLabel = Instance.new("TextLabel")
            dropdownLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
            dropdownLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
            dropdownLabel.BackgroundTransparency = 1
            dropdownLabel.Text = name
            dropdownLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
            dropdownLabel.TextSize = scale(14)
            dropdownLabel.Font = Enum.Font.Gotham
            dropdownLabel.TextXAlignment = Enum.TextXAlignment.Left
            dropdownLabel.Parent = dropdownFrame

            local dropdownButton = Instance.new("TextButton")
            dropdownButton.Size = UDim2.new(0, scale(100), 0, scale(20))
            dropdownButton.Position = UDim2.new(1, -scale(105), 0, scale(10))
            dropdownButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
            dropdownButton.BackgroundTransparency = 0
            dropdownButton.Text = default or options[1] or "Select"
            dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
            dropdownButton.TextSize = scale(12)
            dropdownButton.Font = Enum.Font.Gotham
            dropdownButton.Parent = dropdownFrame
            createCorner(dropdownButton, scale(6))

            local dropdownList = Instance.new("ScrollingFrame")
            dropdownList.Size = UDim2.new(0, scale(100), 0, 0)
            dropdownList.Position = UDim2.new(1, -scale(105), 0, scale(30))
            dropdownList.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
            dropdownList.BorderSizePixel = 0
            dropdownList.ScrollBarThickness = scale(5)
            dropdownList.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 100)
            dropdownList.ZIndex = 100
            dropdownList.Visible = false
            dropdownList.Parent = screenGui
            createCorner(dropdownList, scale(6))
            createStroke(dropdownList)

            local listLayout = Instance.new("UIListLayout")
            listLayout.Padding = UDim.new(0, scale(2))
            listLayout.Parent = dropdownList

            local currentSelection = default or options[1]
            local isOpen = false

            local function updateDropdown()
                dropdownButton.Text = currentSelection
                if callback then callback(currentSelection) end
            end

            local function toggleDropdown()
                isOpen = not isOpen
                dropdownList.Visible = isOpen
                if isOpen then
                    local height = math.min(#options * scale(25), scale(125))
                    dropdownList.Size = UDim2.new(0, scale(100), 0, height)
                    dropdownList.CanvasSize = UDim2.new(0, 0, 0, #options * scale(25))
                    dropdownList.Position = UDim2.new(0, dropdownButton.AbsolutePosition.X - screenGui.AbsolutePosition.X, 0, dropdownButton.AbsolutePosition.Y - screenGui.AbsolutePosition.Y + scale(25))
                else
                    dropdownList.Size = UDim2.new(0, scale(100), 0, 0)
                end
            end

            for i, option in ipairs(options) do
                local optionButton = Instance.new("TextButton")
                optionButton.Size = UDim2.new(1, -scale(4), 0, scale(25))
                optionButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
                optionButton.BackgroundTransparency = 0
                optionButton.Text = option
                optionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
                optionButton.TextSize = scale(12)
                optionButton.Font = Enum.Font.Gotham
                optionButton.ZIndex = 101
                optionButton.Parent = dropdownList
                createCorner(optionButton, scale(4))
                optionButton.MouseButton1Click:Connect(function()
                    currentSelection = option
                    updateDropdown()
                    toggleDropdown()
                end)
            end

            dropdownButton.MouseButton1Click:Connect(toggleDropdown)

            local conn
            conn = UserInputService.InputBegan:Connect(function(input, processed)
                if not processed and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and isOpen then
                    local pos = input.Position
                    local bPos = dropdownButton.AbsolutePosition
                    local bSize = dropdownButton.AbsoluteSize
                    local lPos = dropdownList.AbsolutePosition
                    local lSize = dropdownList.AbsoluteSize
                    local inButton = pos.X >= bPos.X and pos.X <= bPos.X + bSize.X and pos.Y >= bPos.Y and pos.Y <= bPos.Y + bSize.Y
                    local inList = pos.X >= lPos.X and pos.X <= lPos.X + lSize.X and pos.Y >= lPos.Y and pos.Y <= lPos.Y + lSize.Y
                    if not (inButton or inList) then
                        toggleDropdown()
                    end
                end
            end)

            task.delay(0, function()
                if conn and not dropdownFrame:IsDescendantOf(screenGui) then
                    conn:Disconnect()
                end
            end)

            updateDropdown()
            local dropdownObj = {}
            function dropdownObj:Set(value)
                if table.find(options, value) then
                    currentSelection = value
                    updateDropdown()
                end
            end
            function dropdownObj:Get()
                return currentSelection
            end
            return dropdownObj
        end

        function tabFunctions:input(name, description, placeholder, callback)
            local inputFrame = Instance.new("Frame")
            inputFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
            inputFrame.BackgroundColor3 = COMPONENT_BG_COLOR
            inputFrame.BackgroundTransparency = 0
            inputFrame.Parent = componentsContainer
            createCorner(inputFrame, scale(6))
            createStroke(inputFrame)

            local desc = Instance.new("TextLabel")
            desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
            desc.Position = UDim2.new(0, scale(5), 0, scale(2))
            desc.BackgroundTransparency = 1
            desc.Text = description
            desc.TextColor3 = Color3.fromRGB(150, 150, 150)
            desc.TextSize = scale(10)
            desc.Font = Enum.Font.Gotham
            desc.TextXAlignment = Enum.TextXAlignment.Left
            desc.Parent = inputFrame

            local inputLabel = Instance.new("TextLabel")
            inputLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
            inputLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
            inputLabel.BackgroundTransparency = 1
            inputLabel.Text = name
            inputLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
            inputLabel.TextSize = scale(14)
            inputLabel.Font = Enum.Font.Gotham
            inputLabel.TextXAlignment = Enum.TextXAlignment.Left
            inputLabel.Parent = inputFrame

            local textBox = Instance.new("TextBox")
            textBox.Size = UDim2.new(0, scale(100), 0, scale(20))
            textBox.Position = UDim2.new(1, -scale(105), 0, scale(10))
            textBox.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
            textBox.BackgroundTransparency = 0
            textBox.Text = ""
            textBox.PlaceholderText = placeholder or "Enter text..."
            textBox.TextColor3 = Color3.fromRGB(255, 255, 255)
            textBox.TextSize = scale(12)
            textBox.Font = Enum.Font.Gotham
            textBox.ClearTextOnFocus = false
            textBox.Parent = inputFrame
            createCorner(textBox, scale(4))

            textBox.FocusLost:Connect(function(enterPressed)
                if enterPressed and callback then
                    callback(textBox.Text)
                end
            end)

            local inputObj = {}
            function inputObj:Set(value)
                textBox.Text = tostring(value)
            end
            function inputObj:Get()
                return textBox.Text
            end
            return inputObj
        end

        function tabFunctions:label(text, color)
            local labelFrame = Instance.new("Frame")
            labelFrame.Size = UDim2.new(1, -scale(20), 0, scale(25))
            labelFrame.BackgroundTransparency = 1
            labelFrame.Parent = componentsContainer

            local label = Instance.new("TextLabel")
            label.Size = UDim2.new(1, 0, 1, 0)
            label.BackgroundTransparency = 1
            label.Text = text
            label.TextColor3 = color or Color3.fromRGB(255, 255, 255)
            label.TextSize = scale(14)
            label.Font = Enum.Font.Gotham
            label.TextXAlignment = Enum.TextXAlignment.Left
            label.Parent = labelFrame
        end

        function tabFunctions:section(title)
            local sectionFrame = Instance.new("Frame")
            sectionFrame.Size = UDim2.new(1, -scale(20), 0, 0)
            sectionFrame.AutomaticSize = Enum.AutomaticSize.Y
            sectionFrame.BackgroundColor3 = SECTION_BG_COLOR
            sectionFrame.BackgroundTransparency = 0
            sectionFrame.Parent = componentsContainer
            createCorner(sectionFrame, scale(8))
            createStroke(sectionFrame, SECTION_BORDER_COLOR, scale(2))

            local titleBar = Instance.new("Frame")
            titleBar.Size = UDim2.new(1, 0, 0, scale(30))
            titleBar.BackgroundTransparency = 1
            titleBar.Parent = sectionFrame

            local titleLabel = Instance.new("TextLabel")
            titleLabel.Size = UDim2.new(1, -scale(10), 1, 0)
            titleLabel.Position = UDim2.new(0, scale(10), 0, 0)
            titleLabel.BackgroundTransparency = 1
            titleLabel.Text = title
            titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
            titleLabel.TextSize = scale(16)
            titleLabel.Font = Enum.Font.GothamBold
            titleLabel.TextXAlignment = Enum.TextXAlignment.Left
            titleLabel.Parent = titleBar

            createSeparator(sectionFrame, UDim2.new(0, scale(10), 0, scale(30)))

            local contentFrame = Instance.new("Frame")
            contentFrame.Size = UDim2.new(1, 0, 0, 0)
            contentFrame.AutomaticSize = Enum.AutomaticSize.Y
            contentFrame.BackgroundTransparency = 1
            contentFrame.Position = UDim2.new(0, 0, 0, scale(30))
            contentFrame.Parent = sectionFrame

            local contentLayout = Instance.new("UIListLayout", contentFrame)
            contentLayout.Padding = UDim.new(0, scale(10))
            contentLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center

            local sectionFunctions = {}

            function sectionFunctions:Toggle(name, description, callback)
                local toggleFrame = Instance.new("Frame")
                toggleFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
                toggleFrame.BackgroundColor3 = COMPONENT_BG_COLOR
                toggleFrame.BackgroundTransparency = 0
                toggleFrame.Parent = contentFrame
                createCorner(toggleFrame, scale(6))
                createStroke(toggleFrame)

                local desc = Instance.new("TextLabel")
                desc.Size = UDim2.new(1, -scale(50), 0, scale(12))
                desc.Position = UDim2.new(0, scale(5), 0, scale(2))
                desc.BackgroundTransparency = 1
                desc.Text = description
                desc.TextColor3 = Color3.fromRGB(150, 150, 150)
                desc.TextSize = scale(10)
                desc.Font = Enum.Font.Gotham
                desc.TextXAlignment = Enum.TextXAlignment.Left
                desc.Parent = toggleFrame

                local toggle = Instance.new("TextButton")
                toggle.Size = UDim2.new(0, scale(30), 0, scale(15))
                toggle.Position = UDim2.new(1, -scale(35), 0, scale(10))
                toggle.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                toggle.BackgroundTransparency = 0
                toggle.Text = ""
                toggle.Modal = true
                toggle.Parent = toggleFrame
                createCorner(toggle, scale(6))

                local toggleCircle = Instance.new("Frame")
                toggleCircle.Size = UDim2.new(0, scale(12), 0, scale(12))
                toggleCircle.Position = TOGGLE_OFF_POS
                toggleCircle.BackgroundColor3 = TOGGLE_INACTIVE_COLOR
                toggleCircle.Parent = toggle
                createCorner(toggleCircle, scale(6))

                local toggleLabel = Instance.new("TextLabel")
                toggleLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
                toggleLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
                toggleLabel.BackgroundTransparency = 1
                toggleLabel.Text = name
                toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                toggleLabel.TextSize = scale(14)
                toggleLabel.Font = Enum.Font.Gotham
                toggleLabel.TextXAlignment = Enum.TextXAlignment.Left
                toggleLabel.Parent = toggleFrame

                local isActive = false
                local function updateToggle()
                    if isActive then
                        smoothTween(toggleCircle, {Position = TOGGLE_ON_POS, BackgroundColor3 = TOGGLE_ACTIVE_COLOR}, 0.2)
                    else
                        smoothTween(toggleCircle, {Position = TOGGLE_OFF_POS, BackgroundColor3 = TOGGLE_INACTIVE_COLOR}, 0.2)
                    end
                    if callback then callback(isActive) end
                end

                toggle.MouseButton1Click:Connect(function()
                    isActive = not isActive
                    updateToggle()
                end)

                local toggleObj = {}
                function toggleObj:Set(value)
                    isActive = value
                    updateToggle()
                end
                function toggleObj:Get()
                    return isActive
                end
                return toggleObj
            end

            function sectionFunctions:Button(name, description, callback)
                local buttonFrame = Instance.new("Frame")
                buttonFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
                buttonFrame.BackgroundColor3 = COMPONENT_BG_COLOR
                buttonFrame.BackgroundTransparency = 0
                buttonFrame.Parent = contentFrame
                createCorner(buttonFrame, scale(6))
                createStroke(buttonFrame)

                local desc = Instance.new("TextLabel")
                desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
                desc.Position = UDim2.new(0, scale(5), 0, scale(2))
                desc.BackgroundTransparency = 1
                desc.Text = description
                desc.TextColor3 = Color3.fromRGB(150, 150, 150)
                desc.TextSize = scale(10)
                desc.Font = Enum.Font.Gotham
                desc.TextXAlignment = Enum.TextXAlignment.Left
                desc.Parent = buttonFrame

                local button = Instance.new("TextButton")
                button.Size = UDim2.new(1, -scale(20), 0, scale(20))
                button.Position = UDim2.new(0, scale(10), 0, scale(15))
                button.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                button.BackgroundTransparency = 0
                button.Text = name
                button.TextColor3 = Color3.fromRGB(255, 255, 255)
                button.TextSize = scale(14)
                button.Font = Enum.Font.Gotham
                button.Parent = buttonFrame
                createCorner(button, scale(6))

                button.MouseButton1Click:Connect(function()
                    smoothTween(button, {Size = UDim2.new(1, -scale(25), 0, scale(18))}, 0.1)
                    task.delay(0.1, function()
                        smoothTween(button, {Size = UDim2.new(1, -scale(20), 0, scale(20))}, 0.1)
                    end)
                    if callback then callback() end
                end)
            end

            function sectionFunctions:Slider(name, description, min, max, default, callback)
                local sliderFrame = Instance.new("Frame")
                sliderFrame.Size = UDim2.new(1, -scale(20), 0, scale(50))
                sliderFrame.BackgroundColor3 = COMPONENT_BG_COLOR
                sliderFrame.BackgroundTransparency = 0
                sliderFrame.Parent = contentFrame
                createCorner(sliderFrame, scale(6))
                createStroke(sliderFrame)

                local desc = Instance.new("TextLabel")
                desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
                desc.Position = UDim2.new(0, scale(5), 0, scale(2))
                desc.BackgroundTransparency = 1
                desc.Text = description
                desc.TextColor3 = Color3.fromRGB(150, 150, 150)
                desc.TextSize = scale(10)
                desc.Font = Enum.Font.Gotham
                desc.TextXAlignment = Enum.TextXAlignment.Left
                desc.Parent = sliderFrame

                local sliderLabel = Instance.new("TextLabel")
                sliderLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
                sliderLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
                sliderLabel.BackgroundTransparency = 1
                sliderLabel.Text = name
                sliderLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                sliderLabel.TextSize = scale(14)
                sliderLabel.Font = Enum.Font.Gotham
                sliderLabel.TextXAlignment = Enum.TextXAlignment.Left
                sliderLabel.Parent = sliderFrame

                local valueLabel = Instance.new("TextLabel")
                valueLabel.Size = UDim2.new(0, scale(50), 0, scale(18))
                valueLabel.Position = UDim2.new(1, -scale(55), 0, scale(14))
                valueLabel.BackgroundTransparency = 1
                valueLabel.Text = tostring(default)
                valueLabel.TextColor3 = Color3.fromRGB(0, 200, 255)
                valueLabel.TextSize = scale(14)
                valueLabel.Font = Enum.Font.GothamBold
                valueLabel.TextXAlignment = Enum.TextXAlignment.Right
                valueLabel.Parent = sliderFrame

                local sliderTrack = Instance.new("Frame")
                sliderTrack.Size = UDim2.new(1, -scale(20), 0, scale(5))
                sliderTrack.Position = UDim2.new(0, scale(10), 1, -scale(15))
                sliderTrack.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
                sliderTrack.Parent = sliderFrame
                createCorner(sliderTrack, scale(3))

                local sliderFill = Instance.new("Frame")
                sliderFill.Size = UDim2.new(0, 0, 1, 0)
                sliderFill.Position = UDim2.new(0, 0, 0, 0)
                sliderFill.BackgroundColor3 = Color3.fromRGB(0, 200, 255)
                sliderFill.Parent = sliderTrack
                createCorner(sliderFill, scale(3))

                local sliderHitbox = Instance.new("TextButton")
                sliderHitbox.Size = UDim2.new(1, 0, 0, scale(30))
                sliderHitbox.Position = UDim2.new(0, 0, 0.5, -scale(15))
                sliderHitbox.BackgroundTransparency = 1
                sliderHitbox.ZIndex = sliderTrack.ZIndex + 1
                sliderHitbox.Modal = true
                sliderHitbox.Parent = sliderFrame

                local sliderButton = Instance.new("Frame")
                sliderButton.Size = UDim2.new(0, scale(20), 0, scale(20))
                sliderButton.AnchorPoint = Vector2.new(0.5, 0.5)
                sliderButton.Position = UDim2.new(0, 0, 0.5, 0)
                sliderButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
                sliderButton.Parent = sliderTrack
                createCorner(sliderButton, scale(10))

                local currentValue = math.clamp(default or min, min, max)
                local isDragging = false
                local dragStartX = 0
                local startPos = 0

                local function updateSlider(value)
                    currentValue = math.clamp(value, min, max)
                    local ratio = (currentValue - min) / (max - min)
                    sliderFill.Size = UDim2.new(ratio, 0, 1, 0)
                    sliderButton.Position = UDim2.new(ratio, 0, 0.5, 0)
                    valueLabel.Text = string.format("%.2f", currentValue)
                    if callback then callback(currentValue) end
                end

                updateSlider(currentValue)

                local inputChangedConn = nil
                local inputEndedConn = nil

                local function beginDrag(input)
                    isDragging = true
                    dragStartX = input.Position.X
                    startPos = sliderButton.Position.X.Scale * sliderTrack.AbsoluteSize.X + sliderButton.Position.X.Offset
                    if not inputChangedConn then
                        inputChangedConn = UserInputService.InputChanged:Connect(function(inputObj, gp)
                            if isDragging and not gp and (inputObj.UserInputType == Enum.UserInputType.MouseMovement or inputObj.UserInputType == Enum.UserInputType.Touch) then
                                local deltaX = inputObj.Position.X - dragStartX
                                local newX = startPos + deltaX
                                local clampedX = math.clamp(newX, 0, sliderTrack.AbsoluteSize.X)
                                local ratio = clampedX / sliderTrack.AbsoluteSize.X
                                local value = min + ratio * (max - min)
                                updateSlider(value)
                            end
                        end)
                    end
                    if not inputEndedConn then
                        inputEndedConn = UserInputService.InputEnded:Connect(function(inputObj, _)
                            if inputObj.UserInputType == Enum.UserInputType.MouseButton1 or inputObj.UserInputType == Enum.UserInputType.Touch then
                                isDragging = false
                                if inputChangedConn then
                                    inputChangedConn:Disconnect()
                                    inputChangedConn = nil
                                end
                                if inputEndedConn then
                                    inputEndedConn:Disconnect()
                                    inputEndedConn = nil
                                end
                            end
                        end)
                    end
                end

                sliderButton.InputBegan:Connect(beginDrag)
                sliderHitbox.InputBegan:Connect(beginDrag)

                local sliderObj = {}
                function sliderObj:Set(value)
                    updateSlider(value)
                end
                function sliderObj:Get()
                    return currentValue
                end
                return sliderObj
            end

            function sectionFunctions:Dropdown(name, description, options, default, callback)
                local dropdownFrame = Instance.new("Frame")
                dropdownFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
                dropdownFrame.BackgroundColor3 = COMPONENT_BG_COLOR
                dropdownFrame.BackgroundTransparency = 0
                dropdownFrame.Parent = contentFrame
                createCorner(dropdownFrame, scale(6))
                createStroke(dropdownFrame)

                local desc = Instance.new("TextLabel")
                desc.Size = UDim2.new(1, -scale(50), 0, scale(12))
                desc.Position = UDim2.new(0, scale(5), 0, scale(2))
                desc.BackgroundTransparency = 1
                desc.Text = description
                desc.TextColor3 = Color3.fromRGB(150, 150, 150)
                desc.TextSize = scale(10)
                desc.Font = Enum.Font.Gotham
                desc.TextXAlignment = Enum.TextXAlignment.Left
                desc.Parent = dropdownFrame

                local dropdownLabel = Instance.new("TextLabel")
                dropdownLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
                dropdownLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
                dropdownLabel.BackgroundTransparency = 1
                dropdownLabel.Text = name
                dropdownLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                dropdownLabel.TextSize = scale(14)
                dropdownLabel.Font = Enum.Font.Gotham
                dropdownLabel.TextXAlignment = Enum.TextXAlignment.Left
                dropdownLabel.Parent = dropdownFrame

                local dropdownButton = Instance.new("TextButton")
                dropdownButton.Size = UDim2.new(0, scale(100), 0, scale(20))
                dropdownButton.Position = UDim2.new(1, -scale(105), 0, scale(10))
                dropdownButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                dropdownButton.BackgroundTransparency = 0
                dropdownButton.Text = default or options[1] or "Select"
                dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
                dropdownButton.TextSize = scale(12)
                dropdownButton.Font = Enum.Font.Gotham
                dropdownButton.Parent = dropdownFrame
                createCorner(dropdownButton, scale(6))

                local dropdownList = Instance.new("ScrollingFrame")
                dropdownList.Size = UDim2.new(0, scale(100), 0, 0)
                dropdownList.Position = UDim2.new(1, -scale(105), 0, scale(30))
                dropdownList.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
                dropdownList.BorderSizePixel = 0
                dropdownList.ScrollBarThickness = scale(5)
                dropdownList.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 100)
                dropdownList.ZIndex = 100
                dropdownList.Visible = false
                dropdownList.Parent = screenGui
                createCorner(dropdownList, scale(6))
                createStroke(dropdownList)

                local listLayout = Instance.new("UIListLayout")
                listLayout.Padding = UDim.new(0, scale(2))
                listLayout.Parent = dropdownList

                local currentSelection = default or options[1]
                local isOpen = false

                local function updateDropdown()
                    dropdownButton.Text = currentSelection
                    if callback then callback(currentSelection) end
                end

                local function toggleDropdown()
                    isOpen = not isOpen
                    dropdownList.Visible = isOpen
                    if isOpen then
                        local height = math.min(#options * scale(25), scale(125))
                        dropdownList.Size = UDim2.new(0, scale(100), 0, height)
                        dropdownList.CanvasSize = UDim2.new(0, 0, 0, #options * scale(25))
                        local absPos = dropdownButton.AbsolutePosition - screenGui.AbsolutePosition + Vector2.new(0, scale(25))
                        dropdownList.Position = UDim2.fromOffset(absPos.X, absPos.Y)
                    else
                        dropdownList.Size = UDim2.new(0, scale(100), 0, 0)
                    end
                end

                for i, option in ipairs(options) do
                    local optionButton = Instance.new("TextButton")
                    optionButton.Size = UDim2.new(1, -scale(4), 0, scale(25))
                    optionButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
                    optionButton.BackgroundTransparency = 0
                    optionButton.Text = option
                    optionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
                    optionButton.TextSize = scale(12)
                    optionButton.Font = Enum.Font.Gotham
                    optionButton.ZIndex = 101
                    optionButton.Parent = dropdownList
                    createCorner(optionButton, scale(4))
                    optionButton.MouseButton1Click:Connect(function()
                        currentSelection = option
                        updateDropdown()
                        toggleDropdown()
                    end)
                end

                dropdownButton.MouseButton1Click:Connect(toggleDropdown)

                local conn
                conn = UserInputService.InputBegan:Connect(function(input, processed)
                    if not processed and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) and isOpen then
                        local pos = input.Position
                        local bPos = dropdownButton.AbsolutePosition
                        local bSize = dropdownButton.AbsoluteSize
                        local lPos = dropdownList.AbsolutePosition
                        local lSize = dropdownList.AbsoluteSize
                        local inButton = pos.X >= bPos.X and pos.X <= bPos.X + bSize.X and pos.Y >= bPos.Y and pos.Y <= bPos.Y + bSize.Y
                        local inList = pos.X >= lPos.X and pos.X <= lPos.X + lSize.X and pos.Y >= lPos.Y and pos.Y <= lPos.Y + lSize.Y
                        if not (inButton or inList) then
                            toggleDropdown()
                        end
                    end
                end)

                task.delay(0, function()
                    if conn and not dropdownFrame:IsDescendantOf(screenGui) then
                        conn:Disconnect()
                    end
                end)

                updateDropdown()
                local dropdownObj = {}
                function dropdownObj:Set(value)
                    if table.find(options, value) then
                        currentSelection = value
                        updateDropdown()
                    end
                end
                function dropdownObj:Get()
                    return currentSelection
                end
                return dropdownObj
            end

            function sectionFunctions:Input(name, description, placeholder, callback)
                local inputFrame = Instance.new("Frame")
                inputFrame.Size = UDim2.new(1, -scale(20), 0, scale(35))
                inputFrame.BackgroundColor3 = COMPONENT_BG_COLOR
                inputFrame.BackgroundTransparency = 0
                inputFrame.Parent = contentFrame
                createCorner(inputFrame, scale(6))
                createStroke(inputFrame)

                local desc = Instance.new("TextLabel")
                desc.Size = UDim2.new(1, -scale(10), 0, scale(12))
                desc.Position = UDim2.new(0, scale(5), 0, scale(2))
                desc.BackgroundTransparency = 1
                desc.Text = description
                desc.TextColor3 = Color3.fromRGB(150, 150, 150)
                desc.TextSize = scale(10)
                desc.Font = Enum.Font.Gotham
                desc.TextXAlignment = Enum.TextXAlignment.Left
                desc.Parent = inputFrame

                local inputLabel = Instance.new("TextLabel")
                inputLabel.Size = UDim2.new(0, scale(150), 0, scale(18))
                inputLabel.Position = UDim2.new(0, scale(5), 0, scale(14))
                inputLabel.BackgroundTransparency = 1
                inputLabel.Text = name
                inputLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                inputLabel.TextSize = scale(14)
                inputLabel.Font = Enum.Font.Gotham
                inputLabel.TextXAlignment = Enum.TextXAlignment.Left
                inputLabel.Parent = inputFrame

                local textBox = Instance.new("TextBox")
                textBox.Size = UDim2.new(0, scale(100), 0, scale(20))
                textBox.Position = UDim2.new(1, -scale(105), 0, scale(10))
                textBox.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                textBox.BackgroundTransparency = 0
                textBox.Text = ""
                textBox.PlaceholderText = placeholder or "Enter text..."
                textBox.TextColor3 = Color3.fromRGB(255, 255, 255)
                textBox.TextSize = scale(12)
                textBox.Font = Enum.Font.Gotham
                textBox.ClearTextOnFocus = false
                textBox.Parent = inputFrame
                createCorner(textBox, scale(4))

                textBox.FocusLost:Connect(function(enterPressed)
                    if enterPressed and callback then
                        callback(textBox.Text)
                    end
                end)

                local inputObj = {}
                function inputObj:Set(value)
                    textBox.Text = tostring(value)
                end
                function inputObj:Get()
                    return textBox.Text
                end
                return inputObj
            end

            function sectionFunctions:Label(text, color)
                local labelFrame = Instance.new("Frame")
                labelFrame.Size = UDim2.new(1, -scale(20), 0, scale(25))
                labelFrame.BackgroundTransparency = 1
                labelFrame.Parent = contentFrame

                local label = Instance.new("TextLabel")
                label.Size = UDim2.new(1, 0, 1, 0)
                label.BackgroundTransparency = 1
                label.Text = text
                label.TextColor3 = color or Color3.fromRGB(255, 255, 255)
                label.TextSize = scale(14)
                label.Font = Enum.Font.Gotham
                label.TextXAlignment = Enum.TextXAlignment.Left
                label.Parent = labelFrame
            end

            function sectionFunctions:ExpandList(name, description, items)
                local expandListFrame = Instance.new("Frame")
                expandListFrame.Size = UDim2.new(1, -scale(20), 0, scale(30))
                expandListFrame.BackgroundTransparency = 1
                expandListFrame.Parent = contentFrame

                local container = Instance.new("Frame")
                container.Size = UDim2.new(1, 0, 1, 0)
                container.BackgroundColor3 = COMPONENT_BG_COLOR
                container.Parent = expandListFrame
                createCorner(container, scale(6))
                createStroke(container)

                local titleBar = Instance.new("Frame")
                titleBar.Size = UDim2.new(1, 0, 0, scale(30))
                titleBar.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
                titleBar.Parent = container
                createCorner(titleBar, scale(6))

                local titleLabel = Instance.new("TextLabel")
                titleLabel.Text = name
                titleLabel.Font = Enum.Font.Gotham
                titleLabel.TextSize = scale(14)
                titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                titleLabel.Size = UDim2.new(0.8, 0, 1, 0)
                titleLabel.Position = UDim2.new(0.1, 0, 0, 0)
                titleLabel.BackgroundTransparency = 1
                titleLabel.TextXAlignment = Enum.TextXAlignment.Left
                titleLabel.Parent = titleBar

                local toggleButton = Instance.new("TextButton")
                toggleButton.Text = "+"
                toggleButton.Font = Enum.Font.GothamBold
                toggleButton.TextSize = scale(16)
                toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
                toggleButton.Size = UDim2.new(0.2, 0, 1, 0)
                toggleButton.Position = UDim2.new(0.8, 0, 0, 0)
                toggleButton.BackgroundTransparency = 1
                toggleButton.Parent = titleBar

                local contentArea = Instance.new("ScrollingFrame")
                contentArea.Size = UDim2.new(1, 0, 0, 0)
                contentArea.Position = UDim2.new(0, 0, 0, scale(30))
                contentArea.BackgroundTransparency = 1
                contentArea.ScrollBarThickness = scale(4)
                contentArea.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 100)
                contentArea.AutomaticCanvasSize = Enum.AutomaticSize.Y
                contentArea.Visible = false
                contentArea.Parent = container

                local contentLayout = Instance.new("UIListLayout", contentArea)
                contentLayout.Padding = UDim.new(0, scale(5))

                local searchBox = Instance.new("Frame")
                searchBox.Size = UDim2.new(1, -scale(10), 0, scale(30))
                searchBox.Position = UDim2.new(0, scale(5), 0, 0)
                searchBox.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                searchBox.Parent = contentArea
                createCorner(searchBox, scale(6))

                local searchLabel = Instance.new("TextLabel")
                searchLabel.Text = "搜索:"
                searchLabel.Font = Enum.Font.Gotham
                searchLabel.TextSize = scale(12)
                searchLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
                searchLabel.Size = UDim2.new(0.2, 0, 1, 0)
                searchLabel.BackgroundTransparency = 1
                searchLabel.Parent = searchBox

                local searchInput = Instance.new("TextBox")
                searchInput.Size = UDim2.new(0.8, 0, 1, 0)
                searchInput.Position = UDim2.new(0.2, 0, 0, 0)
                searchInput.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
                searchInput.TextColor3 = Color3.fromRGB(255, 255, 255)
                searchInput.Font = Enum.Font.Gotham
                searchInput.TextSize = scale(12)
                searchInput.PlaceholderText = "输入关键词..."
                searchInput.PlaceholderColor3 = Color3.fromRGB(150, 150, 150)
                searchInput.Parent = searchBox
                createCorner(searchInput, scale(4))

                local itemsContainer = Instance.new("Frame")
                itemsContainer.Size = UDim2.new(1, -scale(10), 0, 0)
                itemsContainer.Position = UDim2.new(0, scale(5), 0, scale(35))
                itemsContainer.AutomaticSize = Enum.AutomaticSize.Y
                itemsContainer.BackgroundTransparency = 1
                itemsContainer.Parent = contentArea

                local itemsLayout = Instance.new("UIListLayout", itemsContainer)
                itemsLayout.Padding = UDim.new(0, scale(5))

                for _, item in ipairs(items or {}) do
                    if item.Type == "Checkbox" or item.Type == "多选" then
                        local checkboxFrame = Instance.new("Frame")
                        checkboxFrame.Size = UDim2.new(1, 0, 0, scale(25))
                        checkboxFrame.BackgroundTransparency = 1
                        checkboxFrame.Parent = itemsContainer

                        local checkbox = Instance.new("TextButton")
                        checkbox.Text = ""
                        checkbox.Size = UDim2.new(0, scale(18), 0, scale(18))
                        checkbox.Position = UDim2.new(0, scale(5), 0, scale(3))
                        checkbox.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                        checkbox.Parent = checkboxFrame
                        createCorner(checkbox, scale(4))

                        local checkboxLabel = Instance.new("TextLabel")
                        checkboxLabel.Text = item.Text
                        checkboxLabel.Font = Enum.Font.Gotham
                        checkboxLabel.TextSize = scale(12)
                        checkboxLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                        checkboxLabel.Size = UDim2.new(0.9, -scale(28), 1, 0)
                        checkboxLabel.Position = UDim2.new(0, scale(30), 0, 0)
                        checkboxLabel.BackgroundTransparency = 1
                        checkboxLabel.Parent = checkboxFrame

                        checkbox.MouseButton1Click:Connect(function()
                            if checkbox.BackgroundColor3 == Color3.fromRGB(70, 70, 70) then
                                smoothTween(checkbox, {BackgroundColor3 = Color3.fromRGB(0, 200, 255)}, 0.2)
                                pcall(item.Callback, true)
                            else
                                smoothTween(checkbox, {BackgroundColor3 = Color3.fromRGB(70, 70, 70)}, 0.2)
                                pcall(item.Callback, false)
                            end
                        end)
                    elseif item.Type == "Radio" or item.Type == "单选" then
                        local radioFrame = Instance.new("Frame")
                        radioFrame.Size = UDim2.new(1, 0, 0, scale(25))
                        radioFrame.BackgroundTransparency = 1
                        radioFrame.Parent = itemsContainer

                        local radioButton = Instance.new("TextButton")
                        radioButton.Text = ""
                        radioButton.Size = UDim2.new(0, scale(18), 0, scale(18))
                        radioButton.Position = UDim2.new(0, scale(5), 0, scale(3))
                        radioButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                        radioButton.Parent = radioFrame
                        createCorner(radioButton, scale(9))

                        local radioLabel = Instance.new("TextLabel")
                        radioLabel.Text = item.Text
                        radioLabel.Font = Enum.Font.Gotham
                        radioLabel.TextSize = scale(12)
                        radioLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                        radioLabel.Size = UDim2.new(0.9, -scale(28), 1, 0)
                        radioLabel.Position = UDim2.new(0, scale(30), 0, 0)
                        radioLabel.BackgroundTransparency = 1
                        radioLabel.Parent = radioFrame

                        radioButton.MouseButton1Click:Connect(function()
                            for _, radio in ipairs(itemsContainer:GetChildren()) do
                                if radio:IsA("Frame") then
                                    for _, child in ipairs(radio:GetChildren()) do
                                        if child:IsA("TextButton") then
                                            smoothTween(child, {BackgroundColor3 = Color3.fromRGB(70, 70, 70)}, 0.2)
                                        end
                                    end
                                end
                            end
                            smoothTween(radioButton, {BackgroundColor3 = Color3.fromRGB(0, 200, 255)}, 0.2)
                            pcall(item.Callback)
                        end)
                    elseif item.Type == "Tag" or item.Type == "标签" then
                        local tagFrame = Instance.new("Frame")
                        tagFrame.Size = UDim2.new(0.3, 0, 0, scale(25))
                        tagFrame.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
                        tagFrame.Parent = itemsContainer
                        createCorner(tagFrame, scale(4))

                        local tagLabel = Instance.new("TextLabel")
                        tagLabel.Text = item.Text
                        tagLabel.Font = Enum.Font.Gotham
                        tagLabel.TextSize = scale(12)
                        tagLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                        tagLabel.Size = UDim2.new(1, -scale(10), 1, 0)
                        tagLabel.Position = UDim2.new(0, scale(10), 0, 0)
                        tagLabel.BackgroundTransparency = 1
                        tagLabel.Parent = tagFrame
                    end
                end

                searchInput.FocusLost:Connect(function()
                    local searchText = searchInput.Text:lower()
                    for _, child in ipairs(itemsContainer:GetChildren()) do
                        if child:IsA("Frame") then
                            local textLabel = child:FindFirstChildOfClass("TextLabel")
                            local text = textLabel and textLabel.Text:lower() or ""
                            child.Visible = text:find(searchText) ~= nil
                        end
                    end
                end)

                toggleButton.MouseButton1Click:Connect(function()
                    if toggleButton.Text == "+" then
                        toggleButton.Text = "-"
                        contentArea.Visible = true
                        smoothTween(expandListFrame, {Size = UDim2.new(1, -scale(20), 0, scale(200))}, 0.2)
                        contentArea.Size = UDim2.new(1, 0, 1, -scale(30))
                    else
                        toggleButton.Text = "+"
                        smoothTween(expandListFrame, {Size = UDim2.new(1, -scale(20), 0, scale(30))}, 0.2)
                        contentArea.Size = UDim2.new(1, 0, 0, 0)
                        contentArea.Visible = false
                    end
                end)

                local expandListObj = {}
                function expandListObj:SetVisible(visible)
                    if visible then
                        toggleButton.Text = "-"
                        contentArea.Visible = true
                        expandListFrame.Size = UDim2.new(1, -scale(20), 0, scale(200))
                        contentArea.Size = UDim2.new(1, 0, 1, -scale(30))
                    else
                        toggleButton.Text = "+"
                        expandListFrame.Size = UDim2.new(1, -scale(20), 0, scale(30))
                        contentArea.Size = UDim2.new(1, 0, 0, 0)
                        contentArea.Visible = false
                    end
                end
                return expandListObj
            end

            return sectionFunctions
        end

        local tabEntry = {frame = tabContentFrame, button = tabButton}
        table.insert(self, tabEntry)
        tabFunctions.frame = tabContentFrame
        return tabFunctions
    end

    local configTabObj = tabs:tab("(Hidden) Config")
    local configTabButton = configTabObj.button

    do
        local cfg = configTabObj
        local appearance = cfg:section("外观设置")
appearance:Input("主窗口缩放", "调整 UI 主窗口尺寸（建议 0.5 ~ 2.0）", tostring(config.uiScale), function(text)
    local v = tonumber(text)
    if v then
        v = math.clamp(v, 0.5, 2.0)
        config.uiScale = v
        refreshUIScale()
        saveConfig()
    else
        warn("输入值无效，应为数字。")
    end
end):Set(tostring(config.uiScale))

appearance:Input("悬浮按钮缩放", "调整 restore 按钮大小（建议 0.5 ~ 2.0）", tostring(config.restoreButtonScale), function(text)
    local v = tonumber(text)
    if v then
        v = math.clamp(v, 0.5, 2.0)
        config.restoreButtonScale = v
        refreshUIScale()
        saveConfig()
    else
        warn("输入值无效，应为数字。")
    end
end):Set(tostring(config.restoreButtonScale))

appearance:Input("窗口透明度", "背景透明度（0 ~ 1）", tostring(config.windowTransparency), function(text)
    local v = tonumber(text)
    if v then
        v = math.clamp(v, 0, 1)
        config.windowTransparency = v
        mainFrame.BackgroundTransparency = v
        restoreButton.BackgroundTransparency = v
        saveConfig()
    else
        warn("输入值无效，应为数字。")
    end
end):Set(tostring(config.windowTransparency))

appearance:Input("圆角大小", "UI 圆角半径（整数，建议 0 ~ 30）", tostring(config.cornerRadius), function(text)
    local v = tonumber(text)
    if v then
        v = math.clamp(math.floor(v + 0.5), 0, 30)
        config.cornerRadius = v
        mainCorner.CornerRadius = UDim.new(0, v)
        restoreCorner.CornerRadius = UDim.new(0, v)
        saveConfig()
    else
        warn("输入值无效，应为数字。")
    end
end):Set(tostring(config.cornerRadius))

        local behavior = cfg:section("行为设置")
        behavior:Toggle("自动最小化", "关闭 UI 时自动最小化而非销毁", config.autoMinimizeOnClose, function(v)
            config.autoMinimizeOnClose = v
            saveConfig()
        end)

        local theme = cfg:section("主题 & 存储")
        theme:Button("保存配置", "立即将当前设置写入本地", function()
            saveConfig()
        end)
        theme:Button("重置为默认", "恢复初始设置", function()
            config = table.clone(defaultConfig)
            refreshUIScale()
            saveConfig()
        end)
        theme:Button("导出 JSON", "复制配置 JSON 到 Studio 输出", function()
            local json = HttpService:JSONEncode(config)
            warn("📋 Config JSON:\n" .. json)
        end)
    end

    configButton.MouseButton1Click:Connect(function()
    if currentTab and currentTab.button == configTabButton then
        if lastNormalTab and lastNormalTab.button and lastNormalTab.button.Parent then
            lastNormalTab.button:Click()
        else
            lastNormalTab = nil
            for _, tabEntry in ipairs(tabs) do
                if tabEntry.button ~= configTabButton and tabEntry.button.Visible then
                    tabEntry.button:Click()
                    break
                end
            end
        end
    else
        if currentTab and currentTab.button ~= configTabButton then
            lastNormalTab = currentTab
        end
        configTabButton:Click()
    end
end)

    refreshUIScale()
    smoothTween(mainFrame, {Position = UDim2.new(0.5, -scale(175), 0.5, -scale(125))}, 0.5)

    return tabs
end

return SansHubLib